#include "stdafx.h"
#include "vButton.h"

namespace vview
{

IMPLEMENT_RUNTIMEINFO(CVButton, CVView)


CVButton::CVButton()
{
	m_Width = 75;
	m_Height = 23;
	m_buttonState = BS_NORMAL;
	m_TextAlign = TALIGN_LEFT;
}

CVButton::~CVButton()
{

}

void CVButton::SetText(const std::wstring& strText)
{
	if (m_Text != strText)
	{
		m_Text = strText;
		DoNotify(NTYPE_TEXTCHANGED, NULL);
	}
}

std::wstring CVButton::GetText()
{
	return m_Text;
}

void CVButton::SetTextAlign( TextAlign align )
{
	if (m_TextAlign != align)
	{
		m_TextAlign = align;
	}
}

void CVButton::DoNotify(NotifyType nType, DWORD dwParam)
{
	if (NTYPE_MOUSEENTER == nType)
	{
		m_buttonState = BS_OVER;
	}
	else if(NTYPE_MOUSELEAVE == nType)
	{
		m_buttonState = BS_NORMAL;
	}
	else
	{
 		CVView::DoNotify(nType, dwParam);
	}
}

void CVButton::DoMouse(MouseAction Action, ShiftState shift, POINT pt)
{
	if (MACTION_LDOWN == Action)
		m_buttonState = BS_DOWN;
	else if(MACTION_LUP == Action)
		m_buttonState = BS_NORMAL;
}


}